﻿export default {
  // 登录成功
  isLogin (state, loginInfo) {
    if (loginInfo.name) {
      state.userName = decodeURIComponent(loginInfo.name)
    } else {
      if (loginInfo.usertype === 'System') {
        state.userName = '系统管理员'
      } else {
        state.userName = '佚名'
      }
    }
    state.userUid = loginInfo.Login_UID
    state.nameId = loginInfo.nameid
    state.userType = loginInfo.usertype
    state.userNo = loginInfo.userno
    state.roleNo = loginInfo.roleno
    state.avatar = loginInfo.avatar
  },
  // 退出登录
  logout (state) {
    if (sessionStorage) {
      sessionStorage.clear()
    }
    state.userName = ''
    state.userUid = ''
    state.nameId = ''
    state.usertype = ''
    state.userNo = ''
    state.roleNo = ''
    state.avatar = ''
    state.hadRequestError = 0
  },
  // 路由切换时的loading状态
  routeLoading (state, payload) {
    state.routerIsLoading = payload
  },
  // 路由切换时的loading文字
  changeLoadingText (state, payload) {
    state.routerLoadingText = payload
  },
  // 避免出现多次错误提示（请求出错时）
  changeRequestCounts (state, payload) {
    state.hadRequestError = payload
  },
  // 左边菜单的收起和展开的状态
  changSubmenuCollapse (state, payload) {
    state.isCollapse = payload
  },
  // 切换皮肤的方法
  changeCurrentTheme (state, payload) {
    state.currentTheme = payload
  },
  // 路由切换获取屏幕的高度
  changeCurrentRoute (state, payload) {
    state.currentRoute = payload.currentRoute
    sessionStorage.setItem('currentRoute', payload.currentRoute)
  },
  // 更新echart的尺寸
  updateSizeMethod (state, payload) {
    state.updateSize = payload
  },
  // 设定http请求加密
  setHttpEncrypt (state, isEncrypt) {
    state.isHttpEncrypt = isEncrypt
  },
  setShareKey (state, payload) {
    state.shareKey = payload
  },
  setCommonData (state, payload) {
    state.commonData = payload
  }
}
